package com.farm.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Value("${video.basePath}")
    private String uploadPath1;

    @Value("${carousel.basePath}")
    private String uploadPath2;

    @Value("${image.basePath}")
    private String uploadPath3;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/video/**").addResourceLocations("file:"+uploadPath1);

        registry.addResourceHandler("/carousel/**").addResourceLocations("file:"+uploadPath2);

        registry.addResourceHandler("/picture/**").addResourceLocations("file:"+uploadPath3);
        //以下添加更多：
        //registry.addResourceHandler("/picture/**").addResourceLocations("file:"+uploadPath);
    }
}